//
// Created by hi on 25-5-24.
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
 *结构指针
 */
struct student {
    int id;
    char* name;
};
int main() {
    struct student s;
    s.id = 1;
    s.name = (char *)malloc(sizeof(char) * 10);
    strcpy(s.name, "霸霸");
    printf("%s\n", s.name);

    struct student *ps = &s; //获取这个结构体的指针
    ps->id = 1; //使用指针访问结构成员使用->
    (*ps).id = 2; //或者先解构再更改
    printf("%d\n", (*ps).id);
    free(s.name);//释放内存
}